<template>
  <div id="topbarcart" @mouseenter="enter()" @mouseleave="leave()">
    <div id="carttitle">
      <span class="iconfont icon-gouwuchekong m"></span
      ><span class="m">购物车</span><span>（</span
      ><span class="cartNum">{{ cartNum }}</span
      ><span>）</span>
    </div>
    <div class="gooditem">
      <span>购物车中还没有商品，赶紧选购吧！</span>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      cartNum: 0,
    };
  },
  methods: {
    enter() {
      document.getElementById("topbarcart").style.backgroundColor = "#fff";
      document.getElementsByTagName("span").style.color = "#ff6700"
    },
    leave() {
      setTimeout(this.changecolor(), 300);
    },
    changecolor() {
      document.getElementById("topbarcart").style.backgroundColor = "#333";
    },
  },
};
</script>

<style lang='less' >
@import url(../../assets/iconfont/iconfont.css);
#topbarcart {
  position: relative;
  background-color: #424242;
  font: 12px/1.5 Helvetica Neue, Helvetica, Arial, Microsoft Yahei,
    Hiragino Sans GB, Heiti SC, WenQuanYi Micro Hei, sans-serif;
    
  line-height: 42px;
  text-align: center;
  #carttitle {
    z-index: 1;
    height: 40px;
    .iconfont{
      vertical-align: middle;
    }
    span {
      color: #b0b0b0;
    }
    .m {
      margin: 0 2px;
    }
  }
  .gooditem {
    z-index: -1;
    position: absolute;
    top: 40px;
    right: 0px;
    width: 316px;
    height: 0px;
    transition: height 0.3s;
    background-color: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    span{
      display: none;
    }
  }
  &:hover {
    .gooditem {
      height: 100px;
      line-height: 100px;
      span{
        display: block;
      }
    }
  }
}
</style>
